package com.rc.saas.mini.service.elec;

import com.rc.saas.mini.mapper.elec.ElecPileMapper;
import com.rc.saas.mini.model.elec.ElecPile;
import com.rc.saas.mini.model.printer.ElecPileExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/12/18
 */
@Service
public class ElecPileServiceImpl implements ElecPileService {

    @Autowired
    private ElecPileMapper elecPileMapper;

    @Override
    public ElecPileMapper getMapper() {
        return elecPileMapper;
    }

    @Override
    public ElecPile selectPileByPileId(Long pileId) {
        ElecPileExample elecPileExample = new ElecPileExample();
        elecPileExample.createCriteria().andElecPileIdEqualTo(pileId);
        List<ElecPile> elecPiles =  elecPileMapper.selectByExample(elecPileExample);
        if (elecPiles!=null && elecPiles.size()>0){
            return elecPiles.get(0);
        }else {
            return null;
        }
    }

    @Override
    public List<ElecPile> selectByElecStationId(Long elecStationId) {
        ElecPileExample elecPileExample = new ElecPileExample();
        elecPileExample.createCriteria().andElecStationIdEqualTo(elecStationId);
        List<ElecPile> elecPiles = elecPileMapper.selectByExample(elecPileExample);
        return elecPiles;
    }
}
